<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <link rel="stylesheet" href="./bootstrap/css/bootstrap.min.css" />
    <style>
      #app div {
        border: solid;
        margin: 10px;
        font-size: 40px;
      }
    </style>
  </head>

  <body>
    <!-- dom -->
    <div id="app">
      <div>
        <h1>Root</h1>
        <button @click="curCom='tab-news'">news</button>
        <button @click="curCom='tab-foods'">foods</button>
        <button @click="curCom='tab-play'">play</button>
        <hr />
        <!-- 内置 -->
        <component :is="curCom"></component>
      </div>
    </div>
    <script type="module">
      import { createApp, ref } from "./vue.esm-browser.js";
      // 1.导入组件对象
      import TabNews from "./components/TabNews.js";
      import TabFoods from "./components/TabFoods.js";
      import TabPlay from "./components/TabPlay.js";

      const html = String.raw;
      // <root>
      const app = createApp({
        setup() {
          const curCom = ref("tab-news");

          return { curCom };
        },
      });

      // 2 注册组件
      app.component("TabNews", TabNews);
      app.component("TabFoods", TabFoods);
      app.component("TabPlay", TabPlay);

      app.mount("#app"); //挂载
    </script>
  </body>
</html>
